package org.qing.slice.excel;
	
import java.net.URL;

import org.qing.javafx.context.UIContext;
import org.qing.javafx.controller.Controller;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javafx.scene.Parent;
import javafx.scene.Scene;

@SuppressWarnings("restriction")
public class MainApplication extends Application {
	
	private double minWidth = 550d;
	private double minHeight = 450d;
	
	@Override
	public void start(Stage stage) {
		//窗口关闭按钮事件
		stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
			@Override
			public void handle(WindowEvent event) {
				System.exit(0);
			}
		});
		try {
			URL url = getClass().getResource("main.fxml");
			FXMLLoader fXMLLoader = new FXMLLoader(url);
			Parent root = fXMLLoader.load();
			stage.setTitle("Excel分割文件");
			
			stage.setMinWidth(minWidth);
			stage.setMinHeight(minHeight);
			
			Scene scene = new Scene(root,minWidth,minHeight);
			stage.setScene(scene);
			stage.show();
			Controller ctr = fXMLLoader.getController();
			UIContext uIContext = new UIContext();
			uIContext.setStage(stage);
			uIContext.setCurrCtr(this.getClass().getName());
			uIContext.setNextCtr(ctr.getClass().getName());
			ctr.setuIContext(uIContext);
			ctr.init();
		} catch(Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
	}
	
	public static void main(String[] args) {
		launch(args);
	}
}
